package cn.kgc.dto;

import cn.kgc.commons.util.AddGroup;
import cn.kgc.commons.util.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;

/**
 * @description: 新增和更新的时候使用同一个类 接收前段传入的参数
 * 新增和更新的后端验证规则是不同的，使用JSR303验证时，需要区分是新增还是更新
 * @author: 石浩杰
 * @date: 2022-11-28 09:06
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel
@ToString
public class PmsBrandDTO {
    @ApiModelProperty(name = "id", value = "主键", dataType = "int")
    @NotNull(message = "主键不能为空",groups = {UpdateGroup.class})
    private Long id; //主键


    @ApiModelProperty(name = "name", value = "品牌名", dataType = "java.lang.String")
    @NotBlank(message = "name:品牌名不能为空",groups = {AddGroup.class,UpdateGroup.class})
    @Length(max = 50,message = "name:品牌名字符长度小于50",groups = {AddGroup.class,UpdateGroup.class})
    private String name;    //品牌名


    @ApiModelProperty(name = "logo", value = "品牌logo地址", dataType = "java.lang.String")
    private String logo;    //品牌logo地址


    @ApiModelProperty(name = "descript", value = "介绍", dataType = "java.lang.String")
    private String descript;    //介绍


    @ApiModelProperty(name = "firstLetter", value = "检索首字母", dataType = "java.lang.String")
    @Pattern(regexp = "[a-zA-Z]{1}",message = "firstLetter:检索首字母只能是a-z或者是A-Z之间的字母，且长度必须是1",groups = {AddGroup.class,UpdateGroup.class})
    private String firstLetter;    //检索首字母


    @ApiModelProperty(name = "sort", value = "排序", dataType = "java.lang.Integer")
    @Min(value = 0,message = "sort:排序最小值为0",groups = {AddGroup.class,UpdateGroup.class})
    @Max(value = 10,message = "sort:排序的最大值是10",groups = {AddGroup.class,UpdateGroup.class})
    private Integer sort;    //排序


    private int version;   //版本
}
